#ifndef FITS_CONVERTER_H
#define FITS_CONVERTER_H
#include "CCfits/CCfits"
#include <string>
#include <vector>
#include <ctime>
#include <memory>

class FitsConverter {
public:
    FitsConverter(const std::string& fitsFileName);
    ~FitsConverter();

    // 分配内存，设置图像尺寸
    void allocateData(size_t width = 512, size_t height = 512);

    // 更新指定bin的数据
    void updateBinData(size_t index, const uint16_t* data, size_t dataSize);

    // 设置bin名称
    void setBinName(size_t index, const std::string& name);

    // 获取bin原始数据指针
    uint16_t* getBinDataPtr(size_t index) { return (index < kNumBins) ? binData_[index] : nullptr; }

    // 其他接口
    bool writeFits();

    // 直接公开binData_，便于高效访问
    static constexpr size_t kNumBins = 4;
    uint16_t* binData_[kNumBins];
private:
    std::string fitsFileName_;
    std::string binNames_[kNumBins];
    size_t width_ = 512, height_ = 512;
    void writeHeader(CCfits::FITS& fits);
    void writeDataExtensions(CCfits::FITS& fits);
};

#endif // FITS_CONVERTER_H 